<!-- 操作框标题 -->
<div><span><div id="title_tip" class="t_success">商标操作</div></span></div>
<!-- 操作内容 -->
<style>
    *{margin: 0;padding: 0;border: 0;font-size: 100%;font: inherit;vertical-align: baseline;box-sizing: border-box;}
    ol, ul, li {list-style:none;}
    h1, h2, h3, h4, h5, h6 {font-size:200%;font-weight:normal;}
    :focus {outline: 0;}
    .actionbox{border: 0px solid; width: 500px; height: 350px; font-size: 14px; padding-left: 50px}
    .actionbox ul li, .actionbox .updatePriceBox .updatePriceSetBox{ margin-top: 20px }
    .actionbox .text-select{ border: 1px solid #ccc; width: 120px}
    .actionbox .text-lable{ display: inline-block; width:100px; text-align: right }
    .actionbox .text-content{ display: block; text-align:left; padding-left: 100px; color: #999 }
    .actionbox .text-radio{ width:20px; text-align: left }
    .actionbox .btn{background: rgba(63, 86, 224, 1);color: #FFF;padding: 5px;font-size: 14px; margin-left: 100px}
    .actionbox .btn:hover{cursor: pointer;}
    .actionbox .btn:active{opacity:0.5;}
    #trademarkSn{width: 300px; height: 200px; border: 1px solid #ccc; border-radius: 5px; padding: 10px 10px; resize: none}
</style>
<link href="_STATIC_/global/css/wbox.css" rel="stylesheet" type="text/css" />
<!-- 加载全局js -->
<script type="text/javascript" src="_STATIC_/js/jquery.js"></script>
<script src="_STATIC_/global/js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="_STATIC_/global/js/global.js" type="text/javascript"></script>
<script src="_STATIC_/global/js/common.js?v=<?php echo time(); ?>" type="text/javascript"></script>
<script type="text/javascript">var WWW="_WWW_";var STATIC="_STATIC_";var APP ="_APP_";var USERCLIENT ="PC";</script>

<div class="actionbox">
    <ul>
        <li>
            <span class="text-lable">商标编号：</span>
            <textarea id="trademarkSn" placeholder="例1:40460600&#10;例2:41453223f"></textarea>
            <span class="text-content">1.每行一个商标 格式为:商标号 如:40460600</span>
        </li>
        <li>
            <span class="text-lable">操作类型：</span><select class="text-select" name="actionType" id="actionType">
                <option value="none">--请选择--</option>
                <option value="status" >上下架状态</option>
                <option value="saleStatus" >销售状态</option>
            </select>
        </li>
        <li class="statusBox" style="display: none" >
            <span class="text-lable">上下架状态：</span>
            <input type="radio" name="status" value="1" class="text-radio" />上架
            <input type="radio" name="status" value="2" class="text-radio" />下架
        </li>
        <li class="saleStatusBox"style="display: none" >
            <span class="text-lable">销售状态：</span>
            <input type="radio" name="saleStatus" value="0" class="text-radio" />待售
            <input type="radio" name="saleStatus" value="1" class="text-radio" />已售
        </li>
        <li class="updatePriceBox" style="display: none" >
            <div class="updatePriceTypeBox">
                <span class="text-lable">价格类型：</span>
                <select class="text-select" name="updatePriceType" id="updatePriceType">
                    <option value="">--请选择--</option>
                    <option value="all" >定价</option>
                    <option value="add" >加价</option>
                    <option value="cut" >降价</option>
                </select>
            </div>
            <div class="updatePriceSetBox" style="display: none" >
                <span class="text-lable" id="price-type-text">定价金额：</span>
                <input type="text" value="" id="price-value" maxlength="7" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" style="width: 120px; border: 1px solid #ccc; padding-left: 5px">
            </div>
        </li>
        <li class="buttonBox" style="display: block" >
            <span>
            <button class="btn" id="bubmitBtn">确定修改</button>
            </span>
        </li>
    </ul>
</div>
<script type="text/javascript">
    $("#bubmitBtn").click(function (){
        var data = {};
        data.trademarkSn = $("#trademarkSn").val();
        var actionType = $("#actionType").find("option:selected").val();
        if( actionType != "status" && actionType != "saleStatus" && actionType != "updatePrice" ){
            return errmsg("请选择操作类型");
        }
        data.action = actionType;
        if( actionType == "status" ){
            data.status = parseInt($('.statusBox input[name="status"]:checked').val());
            if( data.status != 1 && data.status != 2 ){
                return errmsg("请正确选择上下架状态!");
            }
        }
        if( actionType == "saleStatus" ){
            data.saleStatus = $('.saleStatusBox input[name="saleStatus"]:checked').val();
            if( data.saleStatus != 0 && data.saleStatus != 1 ){
                return errmsg("请正确选择销售状态!");
            }
        }
        if( actionType == "updatePrice" ){
            data.updatePriceType = $("#updatePriceType").find("option:selected").val();
            data.updatePriceValue = parseInt($("#price-value").val());
            if( data.updatePriceType != "all" && data.updatePriceType != "add" && data.updatePriceType != "cut" ){
                return errmsg("请选择价格类型");
            }
            var reg = /^[1-9][0-9]*$/;
            if(!reg.test(data.updatePriceValue)){
                return errmsg("价格格式不正确!");
            }
        }
        box_waite();
        $.ajax({
            url   : '/member/trademarksbatchhandle/ac/setting.html',
            data  : data,
            cache : false,
            async : false,
            type  : "POST",
            dataType : 'json',
            success  : function (result){
                box_close();
                if(result.status == 0){
                    return errmsg(result.msg);
                }else{
                    top.window.location.reload();
                    return false;
                }
            }
        });
    })

    /**
     * 选择批量操作类型
     */
    $('#actionType').change(function(){
        var actionType = $(this).find("option:selected").val();
        if( actionType == "status" ){
            $(".saleStatusBox").hide();
            $(".updatePriceBox").hide();
            $(".updatePriceSetBox").hide();
            $(".statusBox").show();
        }else if( actionType == "saleStatus" ){
            $(".updatePriceBox").hide();
            $(".updatePriceSetBox").hide();
            $(".statusBox").hide();
            $(".saleStatusBox").show();
        }else if( actionType == "updatePrice" ){
            $(".statusBox").hide();
            $(".saleStatusBox").hide();
            $(".updatePriceSetBox").hide();
            $(".updatePriceBox").show();
        }else{
            $(".statusBox").hide();
            $(".saleStatusBox").hide();
            $(".updatePriceBox").hide();
            $(".updatePriceSetBox").hide();
        }
    })

    /**
     * 选择价格处理类型
     */
    $('#updatePriceType').change(function(){
        var updatePriceType = $(this).find("option:selected").val();
        if( updatePriceType == "all" ){
            $("#price-type-text").html("设置金额:");
            $(".updatePriceSetBox").show();
        }else if( updatePriceType == "add" ){
            $("#price-type-text").html("加价金额:");
            $(".updatePriceSetBox").show();
        }else if( updatePriceType == "cut" ){
            $("#price-type-text").html("降价金额:");
            $(".updatePriceSetBox").show();
        }else{
            $("#price-type-text").html("");
            $(".updatePriceSetBox").hide();
        }
    })
</script>